/*
 * Copyright 2022 NXP
 * SPDX-License-Identifier: MIT
 */

#include "lvgl/lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
#include "custom.h"


void setup_scr_Calendar(lv_ui *ui){

	//Write codes Calendar
	ui->Calendar = lv_obj_create(NULL, NULL);

	//Write codes Calendar_calendar_1
	ui->Calendar_calendar_1 = lv_calendar_create(ui->Calendar, NULL);

	//Write style LV_CALENDAR_PART_BG for Calendar_calendar_1
	static lv_style_t style_Calendar_calendar_1_bg;
	lv_style_reset(&style_Calendar_calendar_1_bg);

	//Write style state: LV_STATE_DEFAULT for style_Calendar_calendar_1_bg
	lv_style_set_bg_color(&style_Calendar_calendar_1_bg, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_Calendar_calendar_1_bg, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Calendar_calendar_1_bg, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Calendar_calendar_1_bg, LV_STATE_DEFAULT, 255);
	lv_style_set_border_color(&style_Calendar_calendar_1_bg, LV_STATE_DEFAULT, lv_color_make(0xc0, 0xc0, 0xc0));
	lv_style_set_border_width(&style_Calendar_calendar_1_bg, LV_STATE_DEFAULT, 1);
	lv_obj_add_style(ui->Calendar_calendar_1, LV_CALENDAR_PART_BG, &style_Calendar_calendar_1_bg);

	//Write style LV_CALENDAR_PART_HEADER for Calendar_calendar_1
	static lv_style_t style_Calendar_calendar_1_header;
	lv_style_reset(&style_Calendar_calendar_1_header);

	//Write style state: LV_STATE_DEFAULT for style_Calendar_calendar_1_header
	lv_style_set_text_color(&style_Calendar_calendar_1_header, LV_STATE_DEFAULT, lv_color_make(0x0D, 0x30, 0x55));
	lv_style_set_text_font(&style_Calendar_calendar_1_header, LV_STATE_DEFAULT, &lv_font_simsun_12);
	lv_style_set_text_letter_space(&style_Calendar_calendar_1_header, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(ui->Calendar_calendar_1, LV_CALENDAR_PART_HEADER, &style_Calendar_calendar_1_header);

	//Write style LV_CALENDAR_PART_DAY_NAMES for Calendar_calendar_1
	static lv_style_t style_Calendar_calendar_1_day_names;
	lv_style_reset(&style_Calendar_calendar_1_day_names);

	//Write style state: LV_STATE_DEFAULT for style_Calendar_calendar_1_day_names
	lv_style_set_text_color(&style_Calendar_calendar_1_day_names, LV_STATE_DEFAULT, lv_color_make(0x0D, 0x30, 0x55));
	lv_style_set_text_font(&style_Calendar_calendar_1_day_names, LV_STATE_DEFAULT, &lv_font_simsun_12);
	lv_obj_add_style(ui->Calendar_calendar_1, LV_CALENDAR_PART_DAY_NAMES, &style_Calendar_calendar_1_day_names);

	//Write style LV_CALENDAR_PART_DATE for Calendar_calendar_1
	static lv_style_t style_Calendar_calendar_1_date;
	lv_style_reset(&style_Calendar_calendar_1_date);

	//Write style state: LV_STATE_DEFAULT for style_Calendar_calendar_1_date
	lv_style_set_text_color(&style_Calendar_calendar_1_date, LV_STATE_DEFAULT, lv_color_make(0x0D, 0x30, 0x55));
	lv_style_set_text_font(&style_Calendar_calendar_1_date, LV_STATE_DEFAULT, &lv_font_simsun_12);

	//Write style state: LV_STATE_FOCUSED for style_Calendar_calendar_1_date
	lv_style_set_bg_color(&style_Calendar_calendar_1_date, LV_STATE_FOCUSED, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_bg_grad_color(&style_Calendar_calendar_1_date, LV_STATE_FOCUSED, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_bg_grad_dir(&style_Calendar_calendar_1_date, LV_STATE_FOCUSED, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Calendar_calendar_1_date, LV_STATE_FOCUSED, 255);
	lv_style_set_text_color(&style_Calendar_calendar_1_date, LV_STATE_FOCUSED, lv_color_make(0x0D, 0x30, 0x55));
	lv_style_set_text_font(&style_Calendar_calendar_1_date, LV_STATE_FOCUSED, &lv_font_simsun_12);

	//Write style state: LV_STATE_CHECKED for style_Calendar_calendar_1_date
	lv_style_set_bg_color(&style_Calendar_calendar_1_date, LV_STATE_CHECKED, lv_color_make(0x04, 0xc2, 0x6b));
	lv_style_set_bg_grad_color(&style_Calendar_calendar_1_date, LV_STATE_CHECKED, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Calendar_calendar_1_date, LV_STATE_CHECKED, LV_GRAD_DIR_HOR);
	lv_style_set_bg_opa(&style_Calendar_calendar_1_date, LV_STATE_CHECKED, 255);
	lv_style_set_text_color(&style_Calendar_calendar_1_date, LV_STATE_CHECKED, lv_color_make(0x0D, 0x30, 0x55));
	lv_style_set_text_font(&style_Calendar_calendar_1_date, LV_STATE_CHECKED, &lv_font_simsun_12);

	//Write style state: LV_STATE_PRESSED for style_Calendar_calendar_1_date
	lv_style_set_bg_color(&style_Calendar_calendar_1_date, LV_STATE_PRESSED, lv_color_make(0x04, 0xc2, 0x6b));
	lv_style_set_bg_grad_color(&style_Calendar_calendar_1_date, LV_STATE_PRESSED, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Calendar_calendar_1_date, LV_STATE_PRESSED, LV_GRAD_DIR_HOR);
	lv_style_set_bg_opa(&style_Calendar_calendar_1_date, LV_STATE_PRESSED, 255);
	lv_style_set_text_color(&style_Calendar_calendar_1_date, LV_STATE_PRESSED, lv_color_make(0x0D, 0x30, 0x55));
	lv_style_set_text_font(&style_Calendar_calendar_1_date, LV_STATE_PRESSED, &lv_font_simsun_12);
	lv_obj_add_style(ui->Calendar_calendar_1, LV_CALENDAR_PART_DATE, &style_Calendar_calendar_1_date);
	lv_obj_set_pos(ui->Calendar_calendar_1, 0, 0);
	lv_obj_set_size(ui->Calendar_calendar_1, 240, 174);
	today.year = 2020;
	today.month = 5;
	today.day = 7;
	lv_calendar_set_today_date(ui->Calendar_calendar_1, &today);
	lv_calendar_set_showed_date(ui->Calendar_calendar_1, &today);
	highlihted_days[0].year = 2020;
	highlihted_days[0].month = 5;
	highlihted_days[0].day = 14;
	lv_calendar_set_highlighted_dates(ui->Calendar_calendar_1, highlihted_days, 1);
	lv_anim_path_t lv_anim_path_Calendar_btn_1 = {.cb = lv_anim_path_linear};

	//Write codes Calendar_btn_1
	ui->Calendar_btn_1 = lv_btn_create(ui->Calendar, NULL);

	//Write style LV_BTN_PART_MAIN for Calendar_btn_1
	static lv_style_t style_Calendar_btn_1_main;
	lv_style_reset(&style_Calendar_btn_1_main);

	//Write style state: LV_STATE_DEFAULT for style_Calendar_btn_1_main
	lv_style_set_radius(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, 50);
	lv_style_set_bg_color(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, 150);
	lv_style_set_border_color(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_border_width(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, 2);
	lv_style_set_border_opa(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, 100);
	lv_style_set_outline_color(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_outline_opa(&style_Calendar_btn_1_main, LV_STATE_DEFAULT, 50);
	lv_obj_add_style(ui->Calendar_btn_1, LV_BTN_PART_MAIN, &style_Calendar_btn_1_main);
	lv_obj_set_pos(ui->Calendar_btn_1, 95, 320);
	lv_obj_set_size(ui->Calendar_btn_1, 50, 50);

	//Write animation: Calendar_btn_1move in y direction
	lv_anim_t Calendar_btn_1_y;
	lv_anim_init(&Calendar_btn_1_y);
	lv_anim_set_var(&Calendar_btn_1_y, ui->Calendar_btn_1);
	lv_anim_set_time(&Calendar_btn_1_y, 300);
	lv_anim_set_exec_cb(&Calendar_btn_1_y, (lv_anim_exec_xcb_t)lv_obj_set_y);
	lv_anim_set_values(&Calendar_btn_1_y, lv_obj_get_y(ui->Calendar_btn_1), 260);
	_lv_memcpy_small(&Calendar_btn_1_y.path, &lv_anim_path_Calendar_btn_1, sizeof(lv_anim_path_cb_t));
	lv_anim_start(&Calendar_btn_1_y);

	ui->Calendar_btn_1_label = lv_label_create(ui->Calendar_btn_1, NULL);
	lv_label_set_text(ui->Calendar_btn_1_label, "<");
	lv_obj_set_style_local_text_color(ui->Calendar_btn_1_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0x00, 0x00, 0x00));
	lv_obj_set_style_local_text_font(ui->Calendar_btn_1_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_simsun_20);

	//Init events for screen
	events_init_Calendar(ui);
}